package com.yukh.dao.mybatis;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;

@SuppressWarnings("unchecked")
public class BaseDao extends SqlSessionDaoSupport{
	
	public void save(String statementName){
		this.getSqlSession().insert(statementName);
	}
	
	public void save(String statementName, Object object){
		this.getSqlSession().insert(statementName, object);
	}
	
	public void update(String statement){
		this.getSqlSession().update(statement);
	}
	
	public void update(String statement, Object object){
		this.getSqlSession().update(statement, object);
	}
	
	public void delete(String statement){
		this.getSqlSession().delete(statement);
	}
	
	public void delete(String statement, Object object){
		this.getSqlSession().delete(statement, object);
	}
	
	public List queryForList(String statementName){
		return this.getSqlSession().selectList(statementName);
	}
	
	public List queryForList(String statementName, Object object){
		return this.getSqlSession().selectList(statementName, object);
	}
	
	public List queryForPage(String statementName, Object object, int offerSet, int size){
		return this.getSqlSession().selectList(statementName, object, 
				new RowBounds(offerSet, offerSet));
	}
	
	public Map queryForMap(String statementName, String mapKey){
		return this.getSqlSession().selectMap(statementName, mapKey);
	}
	
	public Map queryForMap(String statementName,Object object, String mapKey){
		return this.getSqlSession().selectMap(statementName, object, mapKey);
	}
	
}
